<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <input type="text" @keyup.enter="add" v-model="task" />
      <ul>
        <li v-for="item in items">
          {{item}}
          <button @click="deleteData(key)">删除</button>
        </li>
      </ul>
    </div>

    <script src="../lib/vue.js"></script>

    <script>
      let vm = new Vue({
        el: '#app',
        data: {
          items: [],
          task: '',
        },
        methods: {
          add: function () {
            this.items.push(this.task)
          },
          deleteData(key) {
            this.items.splice(key, 1)
          },
        },
      })
    </script>
  </body>
</html>
